package com.atguigu.gulimall.order.controller;

import com.atguigu.gulimall.order.entity.OrderReturnApplyEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.UUID;
/**
 * @author starsPromise
 */
@Slf4j
@Controller
public class RabbitController {
    @Autowired
    RabbitTemplate rabbitTemplate;
    @GetMapping("/sendMsg")
    @ResponseBody
    public String sendMessageTest(){
        OrderReturnApplyEntity orderReturnApplyEntity = new OrderReturnApplyEntity();
        orderReturnApplyEntity.setId(1L);
        orderReturnApplyEntity.setCompanyAddress("test");
        orderReturnApplyEntity.setHandleMan("实时数");
        rabbitTemplate.convertAndSend("hello-java-exchange","hello.java22",orderReturnApplyEntity,new CorrelationData(UUID.randomUUID().toString()));

        log.info("消息发送完成");
        return "ok";
    }
}
